package cn.com.zonesion.rfiddemo.fragment;

import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import cn.com.zonesion.rfiddemo.R;
import cn.com.zonesion.rfiddemo.base.BaseFragment;

public class BasicsFragmet extends BaseFragment{
    @BindView(R.id.radio_group_type)
    RadioGroup radioGroup;
    @BindView(R.id.type_em)
    RadioButton typeEm;
    @BindView(R.id.type_t)
    RadioButton typeT;
    @BindView(R.id.btn_basics_read_card_number)
    Button readCard;
    @BindView(R.id.btn_basics_write_card_number)
    Button writeCard;

    /**
     * Unbinder对象，用来解除ButterKnife与Fragment对象的绑定
     */
    private Unbinder unbinder;


    @Override
    public View initView() {
        View view = View.inflate(mContext, R.layout.basics_item, null);//通过inflater()方法将布局文件转换为一个View对象
        unbinder = ButterKnife.bind(this, view);//将ButterKnife与ICBasicsFragment进行绑定，并返回一个Unbinder对象
        return view;
    }

    @Override
    public void initData() {
        super.initData();
        init();
    }

    private void init() {
        typeEm.setChecked(true);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if(checkedId == typeEm.getId()) {
                    writeCard.setEnabled(false);
                }else if(checkedId == typeT.getId()) {
                    writeCard.setEnabled(true);
                }
            }
        });
    }

    @Override
    public void onDestroyView() {
        //解除ButterKnife与HistoricalFragment的绑定
        unbinder.unbind();
        super.onDestroyView();
    }
    @OnClick({R.id.btn_basics_scavenging,R.id.btn_basics_read_card_number,R.id.btn_basics_write_card_number})
    public void onClick(View view){
        switch (view.getId()) {
            case  R.id.btn_basics_scavenging://清除

                break;
            case R.id.btn_basics_read_card_number://读取卡号

                break;
            case R.id.btn_basics_write_card_number://写入卡号

                break;
        }
    }
}
